# -*- coding: utf-8 -*-

import tables as T
import numpy as N

class Plot1DClass:
    '''The data class accepts a singular numpy array or a list of 
    numpy arrays and assembles them into an object that contains all of
    the information necessary to plot them using matplotlib
    '''
    def __init__(self, data):
        if type(data) is N.ndarray:
            self.dims = 1
            self.xdata = None
            self.ydata = data
        elif type(data) is list and len(data) == 2:
            self.dims = 2
            if type(data[0]) is N.ndarray:
                self.xdata = data[0]
                self.ydata = data[1]
##        elif type(data) is list and len(data) > 2:
##            self.dims = len(data)
##            if type(data[0]) is N.ndarray:
##                self.xdata = data[0]
##                self.ydata = data[0:]

        else:
            print "Incorrect data type provided, not a numpy array, (x,y) list."
            print "Try Again Fool!"
        
        self.dataLabel = '1D-data'
        self.lineStyle = '-'
        self.lineColor = None
        self.lineWidth = 1
        self.markerStyle = None
        self.markerSize = None
    
    def set_label(self, labelStr):
        self.dataLabel = labelStr

    def set_lineStyle(self, styleStr):
        self.lineStyle = styleStr
    
    def set_lineColor(self, colorStr):
        self.lineColor = colorStr

    def set_lineWidth(self, lwStr):
        self.lineWidth = lwStr
    
    def set_markerStyle(self, markerStr):
        self.markerStyle = markerStr
    
    def set_markerSize(self, msStr):
        self.markerSize = msStr
        
    def __xdata__(self):
        if self.dims == 1:
            print "There is no x-data, request y-data instead"
        else:
            return self.xdata
    
    def __ydata__(self):
        return self.ydata
          

if __name__ == "__main__":
    x = N.arange(0,10, N.random.random())
    y = N.cos(x-N.random.random())
    data2plot = Plot1DClass([x,y])
    print type(data2plot)
    print data2plot.dims
    #print data2plot.__ydata__()
    
    a = N.arange(0,20, N.random.random())
    b = N.sin(a)
    data2plot1D = Plot1DClass(b)
    print type(b)
    print data2plot1D.dims
    
##    plot = Plot_Widget(data2plot)
##    plot.show()
##    sys.exit(app.exec_())
